<h3>Thêm mới thành viên</h3>
<style type="text/css">
td {
	border:1px solid #CCC;
	padding:2px 6px;
}
.red{
	color:#F00
}
</style>
<div style="height:30px"></div>
<?php
require("clsusers.php");
if(isset($_POST['submit'])){
	$name = $_POST['username'];
	$pass = md5($_POST['userpass']);
	$fullname = $_POST['userfullname'];
	$gender = $_POST['usergender'];
	$level = $_POST['userlevel'];
	$phone = $_POST['userphone'];
	$email = $_POST['useremail'];
	$user = new users();
	$checkname = $user->checkname($name);
	$checkmail = $user->checkmail($email);
	if($checkname == "false" || $checkmail == "false"){
		echo "Người dùng này đã tồn tại"; die();
	}else{
		$user->add($name,$pass,$fullname,$gender,$phone,$email,$level);
		header("location:".BASEURL."admin/index.php?page=users&act=list");
		exit();
	}
}
?>
<form action="<?php echo BASEURL."admin/index.php?page=users&act=add"; ?>" method="post">
  <table width="442" border="0">
    <tr>
      <td width="140">Tên đăng nhập <span class="red">*</span></td>
      <td width="248"><label id="errorname"></label>
        <input name="username" id="username" type="text" id="username" size="25" />
        </td>
    </tr>
    <tr>
      <td>Mật khẩu <span class="red">*</span></td>
      <td><label for="userpass"></label>
        <input name="userpass" type="password" id="userpass" size="25" /></td>
    </tr>
    <tr>
      <td>Nhập lại mật khẩu <span class="red">*</span></td>
      <td><input name="repass" type="password" id="repass" size="25" /></td>
    </tr>
    <tr>
      <td>Họ tên</td>
      <td><input name="userfullname" type="text" id="userfullname" size="25" /></td>
    </tr>
    <tr>
      <td>Giới tính <span class="red">*</span></td>
      <td>
        <select name="usergender">
          <option>Chọn</option>
          <option value="1">Nam</option>
          <option value="0">Nữ</option>
        </select>
      </td>
    </tr>
    <tr>
      <td>Level <span class="red">*</span></td>
      <td>
      	<select name="userlevel">
          <option value="2">Member</option>
          <option value="1">Administrator</option>
        </select>
      </td>
    </tr>
    <tr>
      <td>Số phone</td>
      <td><input name="userphone" type="text" id="userphone" size="25" /></td>
    </tr>
    <tr>
      <td>Email address <span class="red">*</span></td>
      <td><input name="useremail" type="text" id="useremail" size="25" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" onclick="return checkform()" id="button" value="Add new" />
      <input type="reset" name="reset" id="reset" value="Reset" /></td>
    </tr>
  </table>
</form>